import request from "@/utils/request.ts";
import Enum from "@/api/userApi/enum.ts";
import type { ResponseType } from "@/types/commonTypes/commonTypes.ts";
import type { Patient, UserInfo, UserMessage } from "@/types/userTypes/userTypes.ts";
import type { LoginParams } from "@/types/userTypes/userTypes.ts";

/*密码登录的接口*/
export const passwordLoginAPI = (data: LoginParams): Promise<ResponseType<UserInfo>> => request.post<UserInfo, ResponseType<UserInfo>, LoginParams>(Enum.passwordLogin, data);
/*发送验证码的接口*/
export const sendCodeAPI = (mobile: string, type: string): Promise<ResponseType<{ code: string }>> => request.get<{ code: string }, ResponseType<{ code: string }>, { params: { mobile: string, type: string } }>(Enum.sendCode, { params: { mobile, type } });
/*手机号登录的接口*/
export const mobileLoginAPI = (data: LoginParams): Promise<ResponseType<UserInfo>> => request.post<UserInfo, ResponseType<UserInfo>, LoginParams>(Enum.mobileLogin, data);
/*获取个人信息的接口*/
export const fetchUserMessageAPI = (): Promise<ResponseType<UserMessage>> => request.get<UserMessage, ResponseType<UserMessage>>(Enum.fetchUserInfo);
/*获取患者的接口*/
export const fetchPatientListAPI = (): Promise<ResponseType<Patient[]>> => request.get<Patient[], ResponseType<Patient[]>>(Enum.fetchPatient);
/*删除患者的接口*/
export const deletePatientAPI = (id: string): Promise<ResponseType<{ id: string }>> => request.delete<{ id: string }, ResponseType<{ id: string }>>(`${Enum.deletePatient}/${id}`);
/*添加患者的接口*/
export const addPatientAPI = (data: Patient): Promise<ResponseType<{ id: string }>> => request.post<{ id: string }, ResponseType<{ id: string }>, Patient>(Enum.addPatient, data);
/*编辑患者的接口*/
export const updatePatientAPI = (data: Patient): Promise<ResponseType<{ id: string }>> => request.put<{ id: string }, ResponseType<{ id: string }>, Patient>(Enum.updatePatient, data);
/*查找患者的接口*/
export const findPatientAPI = (id: string): Promise<ResponseType<Patient>> => request.get<Patient, ResponseType<Patient>>(`${Enum.findPatient}/${id}`);
